import request from './request'

// 获取专业列表
export function getMajorList() {
  return request({
    url: '/major/list',
    method: 'get'
  })
}

// 分页查询专业
export function getMajorPage(pageNum = 1, pageSize = 10, majorName = '') {
  return request({
    url: '/major/page',
    method: 'get',
    params: {
      pageNum,
      pageSize,
      majorName
    }
  })
}

// 获取课程列表
export function getCourseList() {
  return request({
    url: '/course/list',
    method: 'get'
  })
}

// 为专业添加课程
export function addCourseToMajor(majorId, courseId) {
  return request({
    url: '/major/addcourse',
    method: 'post',
    params: {
      majorId,
      courseId
    }
  })
}

// 根据专业ID查询已选课程
export function selectByMajorId(majorId) {
  return request({
    url: '/major/selectByMajorId',
    method: 'get',
    params: {
      majorId
    }
  })
}

// 从专业中移除课程
export function removeCourseFromMajor(majorId, courseId) {
  return request({
    url: '/major/remove',
    method: 'delete',
    params: {
      majorId,
      courseId
    }
  })
}

// 删除专业
export function deleteMajor(majorId) {
  return request({
    url: '/major/delete',
    method: 'delete',
    params: {
      majorId
    }
  })
}

// 新增专业
export function addMajor(major) {
  return request({
    url: '/major/add',
    method: 'post',
    data: major
  })
}

